Remove duplicated characters from string