Fixed code for events