refactoring to better handle multiple browser windows (tabs)
refactoring to better handle multiple browser windows (tabs)