further refactoring into templates