improve event loop