Fixed bug with looping based on time limit