started working on buildInversePermutations