util functions for combinations and permutations