refactorage localstorage code
added back a function I errantly removed