Added more comments for explanation. Changed order of calls.

Changed the order of the calls for a beter alert dismissal flow.