fixed the bug that the events are not fired correctly