Templating refactoring