recursive way to do permutation