added a check to identify valid port numbers