Change context manager to normal function