add better port recognition functionality