change local storage to try catch