fix generating all permutation