changed port number calculation