fixed the dismissing of the viewcontroller before alertview