fixed agent filtering issue
Fixed jshint's loopfunc complaint