added simple event loop