Refactor the parts of the templates