fix error logic #3162