implemented remove_chars algorithm