refactored, wrap with template model