refactoring: reduce duplication