refactoring and comments in browserWindow