Implement batch processing
working version