improved port check