Minor refactoring to reduce duplication