some template refactoring to improve future DRY compliance