Refactoring to model