used a do while loop