Improve check_port shell script