use DOM manipulation instead of document.write