added error checks