add code for batching, not complete