using contextmanager instead of decorator