updated port_check to function