fix memory leak , batched processing of records by iterating and adding to a list