refactoring of templates