made DistanceComparator a protected inner class