Added batch processing so that data insertion is more efficient