Added guard to check if UIBarButtonItem's action is set