Refactor the scheduler code for Snooze - Adrien