modified client event handling code to wait for all responses before exiting; tested and there seems to be correctness but performance is bad