fixed the batching process and the error managment