added usedPorts tracking