refactor internal function.escape_str