Fixed IndexOutOfBounds exception