fixing error checks