Refactoring anagram.