fix bugs and add example for browser usage