Refactoring the templates