There was a missing step++ when falling down to the next step in the switch(), which was preventing a proper connection.