adding header and footer, refactoring templates