Refactor find_anagrams.