Refactor for browserify