added two phase wrapper and permutation tool