use a better way to get port number