Added dismissing to try to avoid dismissing more than once