refactor the templates