TemplateUtil refactoring