cross node/browser support/refactor