revised is_permutation