extracted the reset of localstorage to its own function