Looping until a button is pressed

if (IRstate != lastIRstate) {
cases
}
lastIRstate = IRstate;

you dont need this. because the moment it ends the loop and begins again.
the if statement will be false.