edited match_time_intervals function