fixing inner event loop