got a couple of loop values and indexes wrong