refactored the string conversion routine