added check to make sure there's data in the next before localstorage