fixed portCount boundary problem :D