minor if refactoring to avoid repetition