helpers for sample app
diff --git a/package.json b/package.json
index 50bb68e..22678c0 100755
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "random-forest-classifier",
-  "version": "0.0.1",
+  "version": "0.3.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/tree/index.js b/tree/index.js
index bf5afc9..5a2803f 100755
--- a/tree/index.js
+++ b/tree/index.js
@@ -57,7 +57,8 @@
 
 DecisionTreeClassifier.prototype = {
     fit: function(data, features, y) {
-      return utils.C45(data, features, y);
+      var major_label = utils.GetDominate(_.pluck(data, y));
+      return utils.C45(data, features, y, major_label);
     },
     predict: function(sample) {
         var root = this.model;
@@ -71,13 +72,13 @@
             if (root.type === 'feature_real') {
                 var sample_value = parseFloat(sample[attr]);
                 if (sample_value <= root.cut){
-                    child_node = root.children[1];
+                    child_node = root.vals[1];
                 } else {
-                    child_node = root.children[0];
+                    child_node = root.vals[0];
                 }
             } else {
                 var sample_value = sample[attr];
-                var child_node = _.detect(root.children, function(x) {
+                var child_node = _.detect(root.vals, function(x) {
                     return x.name == sample_value;
                 });
             }
diff --git a/utilities/index.js b/utilities/index.js
index ab61731..c92f3d1 100755
--- a/utilities/index.js
+++ b/utilities/index.js
@@ -100,7 +100,7 @@
 }
 
 
-var C45 = function(data, features, y){
+var C45 = function(data, features, y, major_label){
     var tree = {};
     var y_values = _.pluck(data, y);
 
@@ -114,7 +114,16 @@
         };
     }
 
-    if (features === true || y_values.length == 0){
+    if (y_values.length == 0){
+        return {
+            type:"result",
+            val: major_label,
+            name: major_label,
+            alias: major_label + RID()
+        };
+    }
+
+    if (features === true){
         // end of branch
         // returning the most dominate feature
         var dominate_y = GetDominate(y_values);
@@ -143,7 +152,7 @@
             alias: best_feature + RID(),
             cut: best_feature_data.cut,
             type: "feature_real",
-            children: []
+            vals: []
         };
 
         if (feature_remains.length == 0){
@@ -156,8 +165,8 @@
             alias: '>' + tree.cut.toString() + RID(),
             type: "feature_value"
         };
-        child_node_r.child = C45(rightCutData, feature_remains, y);
-        tree.children.push(child_node_r);
+        child_node_r.child = C45(rightCutData, feature_remains, y, major_label);
+        tree.vals.push(child_node_r);
 
         var leftCutData = data.filter(function(x){return x[best_feature] <= best_feature_data.cut});
         var child_node_l = {
@@ -165,18 +174,18 @@
             alias: '<=' + tree.cut.toString() + RID(),
             type: "feature_value"
         };
-        child_node_l.child = C45(leftCutData, feature_remains, y);
-        tree.children.push(child_node_l);
+        child_node_l.child = C45(leftCutData, feature_remains, y, major_label);
+        tree.vals.push(child_node_l);
     } else {
         var possibilities = possibilities = _.unique(_.pluck(data, best_feature));
         tree = {
             name: best_feature,
             alias: best_feature + RID(),
             type: "feature",
-            children: []
+            vals: []
         };
 
-        tree.children = _.map(possibilities, function(v){
+        tree.vals = _.map(possibilities, function(v){
             var data_modified = data.filter(function(x) { return x[best_feature] == v; });
 
             var branch = {
@@ -188,7 +197,7 @@
             if (feature_remains.length == 0){
                 feature_remains = true;
             }
-            branch.child = C45(data_modified, feature_remains, y);
+            branch.child = C45(data_modified, feature_remains, y, major_label);
 
             return branch;
         });
@@ -237,7 +246,7 @@
     };
 
     // create the branch of the tree
-    tree.children = _.map(possibilities, function(v){
+    tree.vals = _.map(possibilities, function(v){
         var data_modified = data.filter(function(x) { return x[best_feature] == v; });
 
         var branch = {
@@ -255,11 +264,48 @@
     });
 
     return tree;
-}
+};
+
+var recursived3ifyModel = function(model){
+    var new_model = {};
+    if (model && model.children){
+        for (var j=0; j < model.children.length; j++){
+            var cleanname = "";
+            if (model.children[j].alias.indexOf("<=") === 0){
+                cleanname += "<= ";
+            } else if (model.children[j].alias.indexOf(">") === 0){
+                cleanname += "> ";
+            }
+            cleanname += model.children[j].name;
+            if (model.children[j].child && model.children[j].child.vals) {
+                model.children[j].children = model.children[j].child.vals;
+                model.children[j] = recursived3ifyModel(model.children[j]);
+            } else if (model.children[j].child && model.children[j].child.type == "result"){
+                cleanname += " " +model.children[j].child.val;
+            }
+            model.children[j].name = cleanname;
+        }
+    }
+
+    return model;
+};
+
+var d3ifyModel = function(trees){
+    var models = [];
+    for (var i=0; i< trees.length; i++){
+        models[i] = {
+            name: trees[i].model.name,
+            children: trees[i].model.vals
+        }
+        models[i] = recursived3ifyModel(models[i]);
+    }
+    return models
+};
 
 
 module.exports.ID3 = ID3;
 module.exports.C45 = C45;
 module.exports.GetType = GetType;
 module.exports.GetDominate = GetDominate;
-module.exports.Average = Average;
\ No newline at end of file
+module.exports.Average = Average;
+module.exports.d3ifyModel = d3ifyModel;
\ No newline at end of file