Added check to sleep to make sure there is work to be done before waiting to execute