solving anagram functionality working