implementing loop-until