Don't you need to set ````port_exists = false```` above this line (ie. inside the outer loop over ````ports````?