Refactor webbrowser loaded

Refactored code to be cleaner