IR receiver troubles

Hello, I've been using a small IR receiver to try and control a small car (just a couple of motors and a base) but i can't seem to get it to work as I would like. The idea was to get the car to be able to turn left and right when it is either travelling backwards or forwards or it is stationary. I use 2 variables to keep track of the left/right forward/backwards commands which are constrained between 0 and 8 and feed the code from the receiver through a series of switch cases to determine how the car should move. However, because the codes seem to arrive in bursts of 3 and up times I can't get the variables to its middle value ie not moving forward or backwards or not turning. Is there any way that I could somehow assign a variable to a range of values between 0 and 8? I'm aware that i could use if statements instead but that wouldn't be practical considering all the different possible movements. Or would there be a way to only take one reading from a burst of codes received? Any help would be much appreciated! cheers

What is this? How is this connected? ..post code