improve the if for #681