Refactored for browserify