Refactored convert_to_str method

[#64430024]