Added functionality to check whether 'OK' or 'Cancel' was clicked and perform required action