added multiDimensional array index algorithm