Added an if statement to handle an alert that may or may not show up.