Use cartesian_product instead of meshgrid