update randomness
diff --git a/package.json b/package.json
index 22678c0..21cfb7e 100755
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "random-forest-classifier",
-  "version": "0.3.0",
+  "version": "0.5.0",
   "description": "A random forest classifier. A random forest is a meta estimator that fits a number of decision tree classifiers on various sub-samples of the dataset and use averaging to improve the predictive accuracy and control over-fitting.",
   "main": "index.js",
   "scripts": {
diff --git a/tests/index.js b/tests/index.js
index 72acfbf..1784b6c 100755
--- a/tests/index.js
+++ b/tests/index.js
@@ -21,10 +21,10 @@
     //"species":"setosa"
   },
   {
-    "length":5,
-    "width":2.3,
-    "petal_length":3.3,
-    "petal_width":1,
+    "length":5.8,
+    "width":2.6,
+    "petal_length":4,
+    "petal_width":1.2,
     //"species":"versicolor"
   },
   {
diff --git a/tree/index.js b/tree/index.js
index 5a2803f..ed62c89 100755
--- a/tree/index.js
+++ b/tree/index.js
@@ -53,12 +53,14 @@
     this.splitter = params.splitter || 'best';
     this.min_samples_split = params.min_samples_split || 2;
     this.min_samples_leaf = params.min_samples_leaf || 1;
+    //this.max_depth = params.max_depth || 5;
+    this.num_tries = params.num_tries || 10;
 };
 
 DecisionTreeClassifier.prototype = {
     fit: function(data, features, y) {
       var major_label = utils.GetDominate(_.pluck(data, y));
-      return utils.C45(data, features, y, major_label);
+      return utils.C45(data, features, y, major_label, this.num_tries);
     },
     predict: function(sample) {
         var root = this.model;
diff --git a/utilities/index.js b/utilities/index.js
index c92f3d1..66cb2e1 100755
--- a/utilities/index.js
+++ b/utilities/index.js
@@ -1,20 +1,47 @@
 var _ = require("underscore");
 
-var Gain = function(data, feature, y){
+Array.prototype.AllValuesSame = function(){
+    if (this.length > 0) {
+        for (var i = 1; i < this.length; i++){
+            if (this[i] !== this[0]){
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
+var Gain = function(data, feature, y, num_tries){
     var attribute_values = _.pluck(data, feature),
         entropy = Entropy(_.pluck(data, y)),
         size = data.length,
         feature_type = GetType(data[0][feature]);
 
     if (feature_type == "float" || feature_type == "int"){
+        var min = _.min(attribute_values);
+        var max = _.max(attribute_values);
+
         var entropies = attribute_values.map(function(n){
-            var cutf = parseFloat(n),
-                _gain = entropy - ConditionalEntropy(data, feature, y, cutf);
-            return {
-                feature: feature,
-                gain: _gain,
-                cut: cutf
-            };
+            var sub_entropies = [];
+
+            // var cutf = parseFloat(n),
+            //     _gain = entropy - ConditionalEntropy(data, feature, y, cutf);
+            // sub_entropies.push({
+            //     feature: feature,
+            //     gain: _gain,
+            //     cut: cutf
+            // });
+
+            for (var i=0; i < num_tries; i++) {
+                var cutf = RandomFloat(min, max),
+                    _gain = entropy - ConditionalEntropy(data, feature, y, cutf);
+                sub_entropies.push({
+                    feature: feature,
+                    gain: _gain,
+                    cut: cutf
+                });
+            }
+            return _.max(sub_entropies, function(e){return e.gain});
         });
         return _.max(entropies, function(e){return e.gain});
     } else {
@@ -32,14 +59,19 @@
     }
 };
 
-var MaxGain = function(data, features, y){
+var MaxGain = function(data, features, y, num_tries){
   var gains = [];
-  for(var i=0; i < features.length; i++) {
-    gains.push(Gain(data, features[i], y));
+  for (var i=0; i < features.length; i++) {
+    gains.push(Gain(data, features[i], y, num_tries));
   }
-  return _.max(gains,function(e){
-    return e.gain;
-  });
+
+  if (_.pluck(gains, 'gain').AllValuesSame){
+    return gains[RandomInt(0, gains.length)];
+  } else {
+    return _.max(gains,function(e){
+      return e.gain;
+    });
+  }
 };
 
 var GetDominate = function(vals){
@@ -100,7 +132,7 @@
 }
 
 
-var C45 = function(data, features, y, major_label){
+var C45 = function(data, features, y, major_label, num_tries){
     var tree = {};
     var y_values = _.pluck(data, y);
 
@@ -140,7 +172,7 @@
         features = _.reject(_.keys(data[0]), function(f){ return f == y; });
     }
 
-    var best_feature_data = MaxGain(data, features, y),
+    var best_feature_data = MaxGain(data, features, y, num_tries),
         best_feature = best_feature_data.feature;
     var feature_remains = _.without(features, best_feature);
     var best_feature_type = GetType(data[0][best_feature]);
@@ -165,7 +197,7 @@
             alias: '>' + tree.cut.toString() + RID(),
             type: "feature_value"
         };
-        child_node_r.child = C45(rightCutData, feature_remains, y, major_label);
+        child_node_r.child = C45(rightCutData, feature_remains, y, major_label, num_tries);
         tree.vals.push(child_node_r);
 
         var leftCutData = data.filter(function(x){return x[best_feature] <= best_feature_data.cut});
@@ -174,7 +206,7 @@
             alias: '<=' + tree.cut.toString() + RID(),
             type: "feature_value"
         };
-        child_node_l.child = C45(leftCutData, feature_remains, y, major_label);
+        child_node_l.child = C45(leftCutData, feature_remains, y, major_label, num_tries);
         tree.vals.push(child_node_l);
     } else {
         var possibilities = possibilities = _.unique(_.pluck(data, best_feature));
@@ -197,7 +229,7 @@
             if (feature_remains.length == 0){
                 feature_remains = true;
             }
-            branch.child = C45(data_modified, feature_remains, y, major_label);
+            branch.child = C45(data_modified, feature_remains, y, major_label, num_tries);
 
             return branch;
         });
@@ -303,6 +335,16 @@
 };
 
 
+var RandomFloat = function (a, b) {
+    return Math.random()*(b-a)+a;
+};
+
+
+var RandomInt = function (a, b) {
+    return Math.floor(Math.random()*(b-a)+a);
+};
+
+
 module.exports.ID3 = ID3;
 module.exports.C45 = C45;
 module.exports.GetType = GetType;