Fix sleep logic