enhance cancel function