refactor localstorage to be a type