Handles all the permutations we have encountered