refactored adjacent ed with permutation method