fixed error with sleep