Fixed an error in event firing