I could but I think it will make code less readable.

The first check happens when it's one button dialog. So we need to check which button should work.
Second check is adding listeners.

First check is not happening every time, When it's two buttons dialog.