add some more error checks
docs