Fixed for loop indexing