Add thread sleep to loop