updated index to properly handle passed in port.