added logic for schedule