Refactor model logic.