fixed really bad bug that would screw up the distance comparison operation