rewrote header function to remove document.write