Removed closePort function and checking port opening