Slight refactoring for with-opening.