permutation iteration code