Refactor. Wrap SleepJS to sleep function.