/**
 *
 * Return true or false if an `<option>` element, or an `<input>` element of type
 * checkbox or radio is currently selected found by given selector.
 *
 * <example>
    :index.html
    <select name="selectbox" id="selectbox">
        <option value="John Doe">John Doe</option>
        <option value="Layla Terry" selected="selected">Layla Terry</option>
        <option value="Bill Gilbert">Bill Gilbert"</option>
    </select>

    :isSelected.js
    client.isSelected('[value="Layla Terry"]', function(err, isSelected) {
        console.log(isSelected); // outputs: true
    });
 * </example>
 *
 * @param   {String}             selector  option element or input of type checkbox or radio
 * @returns {Boolean|Boolean[]}            true if element is selected
 * @callbackParameter error, isSelected
 *
 * @uses protocol/elements, protocol/elementIdSelected
 * @type state
 *
 */

var async = require('async'),
    ErrorHandler = require('../utils/ErrorHandler.js');

module.exports = function isSelected (selector) {

    /*!
     * make sure that callback contains chainit callback
     */
    var callback = arguments[arguments.length - 1];

    /*!
     * parameter check
     */
    if(typeof selector !== 'string') {
        return callback(new ErrorHandler.CommandError('number or type of arguments don\'t agree with isSelected command'));
    }

    var self = this,
        response = {};

    async.waterfall([
        function(cb) {
            self.elements(selector, cb);
        },
        function(res, cb) {
            response.elements = res;
            response.elementIdSelected = [];

            if(res.value.length === 0) {
                // throw NoSuchElement error if no element was found
                return callback(new ErrorHandler(7));
            }

            async.eachSeries(res.value, function(val, seriesCallback) {
                self.elementIdSelected(val.ELEMENT, function(err,res) {
                    if(res) {
                        response.elementIdSelected.push(res);
                    }

                    seriesCallback(err);
                });
            }, cb);
        }
    ], function(err) {

        var value = null;

        if(response.elementIdSelected && response.elementIdSelected.length === 1) {

            value = response.elementIdSelected[0].value;

        } else if(response.elementIdSelected && response.elementIdSelected.length > 1) {

            value = response.elementIdSelected.map(function(res) {
                return res.value;
            });

        }

        callback(err, value, response);

    });

};
@@ -494,18 +494,23 @@
 Terry%22%5D'
-, 
+).then(
 function
@@ -510,21 +510,16 @@
 unction(
-err, 
 isSelect
@@ -892,38 +892,8 @@
 var 
-async = require('async'),%0A    
 Erro
@@ -996,134 +996,8 @@
  %7B%0A%0A
-    /*!%0A     * make sure that callback contains chainit callback%0A     */%0A    var callback = arguments%5Barguments.length - 1%5D;%0A%0A
     
@@ -1209,261 +1209,61 @@
     
-var self = this,%0A        response = %7B%7D;%0A%0A    async.waterfall(%5B%0A        function(cb) %7B%0A            self.elements(selector, cb);%0A        %7D,%0A        function(res, cb) %7B%0A            response.elements = res;%0A            response.elementIdSelected = %5B%5D;%0A%0A    
+return this.elements(selector).then(function(res) %7B%0A%0A
     
@@ -1291,28 +1291,24 @@
 th === 0) %7B%0A
-    
             
@@ -1372,36 +1372,22 @@
         
-    return callback(
+throw 
 new Erro
@@ -1397,23 +1397,18 @@
 ndler(7)
-)
 ;%0A
-    
         
@@ -1422,71 +1422,24 @@
     
-    async.eachSeries(res.value, function(val, seriesCallback) %7B
+var self = this,
 %0A   
@@ -1451,17 +1451,8 @@
     
-    self.
 elem
@@ -1468,255 +1468,50 @@
 cted
-(val.ELEMENT, function(err,res) %7B%0A                    if(res) %7B%0A                        response.elementIdSelected.push(res);%0A                    %7D%0A%0A                    seriesCallback(err);%0A                %7D);%0A            %7D, cb);%0A        %7D%0A    %5D, 
+Commands = %5B%5D;%0A%0A        res.value.forEach(
 func
@@ -1520,23 +1520,23 @@
 on(e
-rr
+lem
 ) %7B%0A
-%0A
         
 var 
@@ -1535,426 +1535,146 @@
     
-var value = null;%0A%0A        if(response.elementIdSelected && response.elementIdSelected.length === 1) %7B%0A%0A            value = response.elementIdSelected%5B0%5D.value;%0A%0A        %7D else if(response.elementIdSelected && response.elementIdSelected.length %3E 1) %7B%0A%0A            value = response.elementIdSelected.map(function(res) %7B%0A                return res.value;%0A            %7D);%0A%0A        %7D%0A%0A        callback(err, value, response
+    elementIdSelectedCommands.push(self.elementIdSelected(elem.ELEMENT));%0A        %7D);%0A%0A        return this.unify(elementIdSelectedCommands
 );%0A%0A

rewritten isSelected