add try catch for window.open