ex_string function modified