refactored scheduling to model
refactored some logic to model