I think cellSizeArr is always a 2-element array (at least there is never an access to the 3rd element). Do you use size 3 here to simplify the loop? Then you could also use `simDim` as its length I guess.