Function removeDuplicateCharacters