fix crash on sleep