added printing to file and checking permutation correctiveness
bug fixes