refactor for browser support