fix last index of for array