fix wrong error hanlding intoduced in 945aef