used document.createElement to fix bugs thanks to help from @brianolson