fixed isPermutation

in corporation with Stevan, with the idea of using the function permutations.