Refactor string mutation implementation