adding error checks