completely functional now with an early (naive) permute function