Completed the minimal first example to full function. The formatting of teh thresholdConditionCode is still very hacky. I am also not quite sure why a threshold condition comes out as type "double"? Will this always be the case (if so it will probably continue to work but if not it will fail).