simplified renderString method
added comments, changed order of methods