minor refactorings into templates