replace doUntil with doWhile