Move some logic intro the scheduler.