Fixed ArrayOutOfBounds exception