improved writing of HTML output