fix for ports not necessarily being adjacent