Added error handling to serial input