refactor for browser