fix bugs with events