added window open and close listeners, may possibly work with localStorage