Why does this only go up through three now? Is it only supposed to go to `N-1` where N is the number of dimensions? This doesn't seem like well generalized code...