bug fix for sleep functions