rewrote time loop for sleep