Terrible lexicographic perm implementation
Make more traditionally imperative