refactor of templates