Bugfix the sleep code