refactored with sched