added a better localstorage implementation