batching refactor