refactor - move logic to model