replace until with while

Signed-off-by: Graham Chiu <compkarori@gmail.com>