implemented the event processing function, and fixed some inconsistensies