Simplified using context managers.