Correctly handle cancellation