Updated localstorage function