error handing bug fix