refactoring renderHtml