Added coding to prevent duplicate dialogs from appearing