I haven't seen anyone testing for the serial buffer being less than empty before.
Nevertheless look very carefully at how your IF statements are organized and ask yourself when the second one will be triggered.
"Very carefully" means go through the code step by step with a pencil and paper.
...R