Modify handleBatch method