added main functionality to dialog;