added some code for permutation stats