changed permutator to a correctly working one