           expr.power()
         else false
 
-      invokeOrDefault: (expr)->
-        result = @invoke(expr)
+      invokeOrDefault: (@action)->
+        result = @findAndPerformAction(@expr)
         if @wasFound()
           result
         else
-          @action(expr)
-
-    class_mixer(_FinalOpenSubExpressionApplcation)
-
-
-    class CloseSub
+          @action(@expr)
+
+    class_mixer(_FinalOpenSubExpressionApplication)
+
+
+    class CloseSubExpression
       initialize: ->
         @handled = false
       invoke: (expression)->
-        logger.info("CloseSub#invoke")
-        _FinalOpenSubExpressionApplcation.build(
-          (expression)-> expression.close()).invoke(expression)
-
-    class_mixer(CloseSub)
-
-    class Pi
+        logger.info("CloseSubExpression#invoke")
+        _FinalOpenSubExpressionApplication.build(expression).
+          invoke((expression)-> expression.close())
+    class_mixer(CloseSubExpression)
+
+
+
+    # TODO this needs to ahve final open sub expression application
+    class AppendPi
       invoke: (expression)->
         _ImplicitMultiplication.build().
           onNumeric(expression).
           append(comps.pi.build())
 
-    class_mixer(Pi)
+    class_mixer(AppendPi)
 
     class SquareRoot extends ExpressionManipulation
       invoke: (expression)->

        else # not closable, not handled, return
          expr

      wasFound: -> @found

      updateWithNewSubexp: (expr, subexp)->


    class_mixer(Negation)

    class OpenSubExpression
      action: (expression)->
        _ImplicitMultiplication.build().
          onNumeric(expression).
          append(comps.expression.build().open())

      invoke: (expression)->
        _FinalOpenSubExpressionApplication.build(expression).
          invokeOrDefault((expression)=> @action(expression))


    class_mixer(OpenSubExpression)

    class _FinalOpenSubExpressionApplication
      initialize: (@expr)->
        @found = false

      findAndPerformAction: (expr)->
        subexp = @nextSubExpression(expr)
        if subexp
          subexp = @findAndPerformAction(subexp)
        if @found # the child element below me was updated
          @updateWithNewSubexp(expr, subexp)
        else if expr instanceof comps.expression and expr.isOpen()
