added extra error checks in callback