refactor code
refactor permutation