partial refactoring of localstorage