refactor model repository