modified to JS files to be used in node and in the browser.