Added cancellation logic.