more reliable code canceling