Changed to lambdas to account for different options in product and permutations