Added new logic.
Added new logic.
Fixed dialog close bug.