fixed to could use both browser and node.js environment.