updated port calculation