Full but untested implementation of Scheduling function