check that cb is defined before calling it