you can cancel at time out like this:
if (timeout) {
if (clause) {this.timeagain = 0; sleep .1;
}
if (this.timeagain>0) {timeout = .1;
}
}
sleep will terminate a timeout until another command calls it. Or atleast it used to

. It should work, because for me, sleep nulls timeout if I don't call timeout again.