refactoring + crossbrowser