Refactor to model