Change convertToString function to tail recursive.