slight refactoring removes duplicate code