an html local storage implementation with duplicated code