refactor to work with browserify