better memory safety in dispatcher_cb