trying to fix memory leak in ingestion script