refactoring to reduce repetition further