saveData function saves dta to local storage.