Finish to implement Cartesian product