custom implementation of cartesian product