updated error checks