refactored cartesian in terms of expand.grid for efficiency