Added alertdialogs and check to win function