added counter to keep track of permutations and for readability