refactoring template builder