Anagrams refactor