refactored for use with browserify