code for fridley paper and some for permutation