Corrected schedule creation function.