portMax calculation fixed