code: function(query) {
                      tsdb.searchLookup(query, true, null, function (data) {
                          receivedResponses++;
                          results.push(perResultFn(query,data));
                          if (receivedResponses == expectedResponses) {
                              if (errorsReceived.length == 0) {
                                  successFn(results);
                              }
                              else {
                                  errorFn(errorsReceived, results);
                              }
  
                          }
                      }, function (error) {
                          receivedResponses++;
                          errorsReceived.push({query:query,msg:error});
                          if (receivedResponses == expectedResponses) {
                              errorFn(errorsReceived, results);
                          }
                      });
                  }
docs: nasty inner function to get around closure issues