copied str2str and make it compilable