fixed IndexOutOfBounds exception