try to fix event loop logic