fix for events and avoid callback not defined