Properly check for cancellation