Refactoring anagram finder