Function xFindClosestIndex