added a sleep loop