Changed Anagram algorithm