cleaned up the exit dialog and added function call