change the algorithm of SimSerial.py