localstorage working, but not using best practices with document.