Solve event loop problem