Fix loop in permutations method