reworked serial communication to be more robust

reworked the serial communication to be more robust
please remove commented code