Fixed unsafe access of localstorage