Use elapsed time as the loop limit
Remove endless loop