working version of matR_batch_dl.r