using connection in a context manager as it was dying before