before some refactoring of event loop