made javascript able to adapt to localstorage being out of date