generalize the batch processing.