move logic to model