make compatible with node and browser