While loop version