updated time_interval function