moved code to getSerialPort function