Added improved dialog handler