sched writing function definition