Updated port-related logic for accuracy