implemented canceling functionality