fixing the bug that will not sort out different type of events