Move from decorator to contextmanager