refactored the schedule recurrence logic