Fixed IndexOutOfBounds exception.