Added serial port check and fine-tuned