template refactoring