updated scheduling function