Fix ArrayIndexOutOfBoundsException