changed the index incrementing of the array