Anagram refactored