Adding looping to scheduler_dequeue()