Finished rewriting handleResponses. Need testing correctness.