Fix loop index type