change a bunch of for loops to do while