hook in event loop