If statement problem

The problem is the command is coming in one character at a time and you run through those if statements after each character. You should receive the entire string before running the if statements.