first implementation of anagram