Fix error checks