refactor all templates