refactor template into smaller classes