fixes distanceFromLineSegment