The code for handling bid and ask is very similar. There's a gang of four pattern that would help merge the logic for handling bid and ask.