fixed for loop to decrement too