fixed to properly release control of port