Is there really a reason to show the dialog if onConfirm doesn't exist?
Perhaps move it to top function?