refatoring for s:permutation(), add a corner case