safer access to window.localStorage