main loop of eventloop