rewritten as a module
added local storage polyfill so that localstorage can be used no matter what