Try storing what the MIDI.read() returns and doing all the switching from that stored variable. It looks like a MIDI.read is not passive but telling the computer you can clear the buffer. Therefore if you read and it is true when you are looking for a false you miss the true response when you read again.