adding templates refactoring