refactored templates with headers and footers