added template for restructuring permutations
resizing function still not working.