replaced "localStorage" with "window.localStorage"