diff --git a/lib/models.js b/lib/models.js
index <HASH>..<HASH> 100644
--- a/lib/models.js
+++ b/lib/models.js
@@ -45,10 +45,10 @@ Models.prototype.run = function(model_id, data, params) {
 
     let batches = [];
     if (this.ml.settings.auto_batch) {
-      for (let ii=0; ii < data.length; ii+=ml.settings.batch_size) {
+      for (let ii=0; ii < data.length; ii+=this.ml.settings.batch_size) {
         // keep all the params except the data list, which will get overloaded
         let batch = cloneDeep(params);
-        batch.data = data.slice(ii, ii+ml.settings.batch_size);
+        batch.data = data.slice(ii, ii+this.ml.settings.batch_size);
         batches.push(batch)
       }
     } else {
Solves "ReferenceError: ml is not defined" #7