fix indexOutOfBounds exception