updated port detection