Template refactoring