Changed code to open serial port, seems to work better