refactor model Template