improve event handling