var async = require('async');
var urlglob = require('urlglob');

/**
 * Wireframe
 * @param  {Object} struc JSON represenation of service structure
 * @param  {Object} procs Object holding all module process
 * @return {Null}       NO return
 */
module.exports = function(workFlow, procsObj) {
    var req, meth, url;

    /**
     * Waterfall Handler
     * @param  {Function} callback return
     * @return {Null}
     */
    var _waterfall = function(callback) {
        _assembleTask(workFlow[meth][url].sync, function(err, task) {
            if (err) return callback(true, 'Invalide Workflow : ' + task);
            var taskArr = [];
            for (var key in task) {
                taskArr.push(task[key]);
            }

            async.waterfall(taskArr, function(err, results) {
                return callback(err, results);
            });

        });
    };

    /**
     * Parallel Handler
     * @param  {Function} callback return
     * @return {Null}
     */
    var _parallel = function(callback) {
        _assembleTask(workFlow[meth][url].async, function(err, task) {
            if (err) return callback(true, 'Invalide Workflow : ' + task);
            async.parallel(task, function(err, results) {
                return callback(err, results);
            });

        });
    };

    /**
     * URL Matcher
     * @param {String}   needle   incoming url
     * @param {Object}   haystack JSON object for
     * @param {Function} callback [description]
     */
    var _urlMatch = function(needle, haystack, callback) {
        var match = null;
        for (var i in haystack) {
            if (urlglob(i, req.url)) {
                match = i;
                break;
            }
        }
        return callback(match);
    };

    var _assembleTask = function(taskList, callback) {
        var task = {};
        var err = false;
        for (var key in taskList) {
            var module = taskList[key].split('.');
            if (!procsObj[module[0]]) return callback(true, module);
            var procsInst = new procsObj[module[0]](req);
            if (!procsInst[module[1]]) return callback(true, module);
            task[key] = procsInst[module[1]];
        }
        return callback(err, task);
    };
    
    var _merge = function (data,callback){
        
        _assembleTask(workFlow[meth][url].merg , function(err,tasks){
            if (err) return callback(true, 'Invalide Workflow : ' + tasks);
            
            for (var key in task){
                
                task[key]()
                
            }
            
        });
    }

    /**
     * Main Method
     * @param  {Object}   req      request object passed from HTTP
     * @param  {Function} callback return
     * @return {Null}
     */
    this.run = function(request, callback) {
        req = request;
        if (!(req.method in workFlow) && !('*' in workFlow)) {
            callback(405, 'Method Not Allowed');
        } else {
            meth = (req.method in workFlow) ? req.method : '*';
            _urlMatch(req.url, workFlow[meth], function(match) {
                if (match === null) {
                    callback(404, 'Not Found');
                } else {
                    var branch = {};
                    url = match;
                    typeof workFlow[meth][url].sync != 'undefined' && (branch.sync = _waterfall);
                    typeof workFlow[meth][url].async != 'undefined' && (branch.async = _parallel);
                    async.parallel(branch, callback);
                    return;
                }
            });
        }
    };
};

@@ -2279,12 +2279,15 @@
 on (
-data
+results
 ,cal
@@ -2349,17 +2349,16 @@
 rl%5D.merg
- 
 , functi
@@ -2364,22 +2364,23 @@
 ion(err,
+ 
 task
-s
 )
+ 
 %7B%0A      
@@ -2445,17 +2445,16 @@
 ' + task
-s
 );%0A     
@@ -2452,32 +2452,49 @@
 k);%0A            
+var taskArr = %5B%5D;
 %0A            for
@@ -2511,16 +2511,17 @@
 in task)
+ 
 %7B%0A      
@@ -2522,32 +2522,56 @@
                 
+taskArr.push(task%5Bkey%5D);
 %0A               
@@ -2571,54 +2571,119 @@
     
+%7D%0A%0A
     
-task%5Bkey%5D()%0A                %0A            %7D
+        async.waterfall(taskArr, function(err, results) %7B%0A                return callback(err, results);
 %0A   
@@ -2683,32 +2683,36 @@
 s);%0A            
+%7D);%0A
 %0A        %7D);%0A   
@@ -3628,24 +3628,165 @@
 branch, 
-callback
+function (err,results)%7B%0A                        %0A                        return merg(results,callback)%0A                        %0A                    %7D
 );%0A     

Update wireframe.js