made recursive function to generate schedules