--- a/src/modules/bugs/functions/Sum.cc
+++ b/src/modules/bugs/functions/Sum.cc
@@ -1,21 +1,24 @@
 #include <config.h>
 #include "Sum.h"
+#include <util/logical.h>
 
 using std::vector;
 
 namespace jags {
 namespace bugs {
 
-    Sum::Sum () : VectorFunction("sum", 1)
+    Sum::Sum () : VectorFunction("sum", 0)
     {
     }
 
     void Sum::evaluate(double *x, vector <double const *> const &args,
 		       vector<unsigned int> const &lengths) const
     {
-	double value = args[0][0];
-	for (unsigned long i = 1; i < lengths[0]; ++i) {
-	    value += args[0][i];
+	double value = 0;
+	for (unsigned int j = 0; j < args.size(); ++j) {
+	    for (unsigned int i = 0; i < lengths[j]; ++i) {
+		value += args[j][i];
+	    }
 	}
 	*x = value;
     }
@@ -27,7 +30,7 @@
 
     bool Sum::isDiscreteValued(vector<bool> const &mask) const
     {
-	return mask[0];
+	return allTrue(mask);
     }
 
     bool Sum::isScale(vector<bool> const &mask, vector<bool> const &fix) const