Refactor the code to use a separate routine that returns a valid serializable string.