Small refactoring to remove repetition