Error in Iterating through permutations

Many thanks for your hint. I will try this solution.