Interval searching function logic changed