Fix localstorage undefined bug