Fix ArrayOutOfBounds error.