refactor for browser api