added a missing $result->close