Cleaned up and made anagram global