fix event loop