added function to generate better string result
fixed bug where isReference was ignored
improved string result