implement batching