ClosestPair implementation