diff --git a/python/dune/perftool/validity.py b/python/dune/perftool/validity.py
index 134ce473f517cf7cfb86581fb291bf42d557f48a..b88b6881f82191e3f6f788ca22907ba1169e97f8 100644
--- a/python/dune/perftool/validity.py
+++ b/python/dune/perftool/validity.py
@@ -1,3 +1,4 @@
+from ufl.classes import Sum
 from ufl.algorithms import MultiFunction
 
 
@@ -37,7 +38,7 @@ class UFLValidityChecker(MultiFunction):
     def sum(self, o, topsum):
         if topsum:
             for op in o.operands():
-                if not isinstance(op, ufl.classes.Sum):
+                if not isinstance(op, Sum):
                     self.sane = len(MultiFunction.__call__(self, op, True)) == self.rank
         else:
             # If this is sum is not part of the topsum, we treat it as all other expressions
@@ -47,7 +48,7 @@ class UFLValidityChecker(MultiFunction):
         assert len(o.operands()) == 2
         if topsum:
             op = o.operands()[0]
-            if not isinstance(op, ufl.classes.Sum):
+            if not isinstance(op, Sum):
                 self.sane = len(MultiFunction.__call__(self, op, True)) == self.rank
         else:
             return self.expr(o, topsum)