added check for receiving nil from serial port