make set localStorage data in a function