fix bug in avoid repeat permutation