Fixed the event code