Fix ArrayIndexOutOfBounds Error