refactor template files