better error checks