reworked serial communication to be more robust

reworked the serial communication to be more robust