another refactoring of valueToString