Added compatibility for chrome and node.js