updated to use document.write