Fixes indexing issue with multidimensional arrays