My advice would be to use a more robust system for receiving data. Have a look at Serial Input Basics
...R