Fixed ArrayIndexOutOfBounds exception