modified select serial port code