Cleaned code for port checks