added loop for time-lapse duration