working version for batch processing