man, I should have thought of putting the if inside the while...
what is $v1?? I looked in the help file and it doesn't explain very much.