changed to until loop