refactored for commonjs