add more error checks