Refactor string converting