fixing array-out-of-bounds