finished refactoring of template