trouble with for loops,indexing