implementation for cancel
added test for canceling