Above you use `var` and `expr`.  Here you use `f.variables[0]` and `f.expr`.  Is there a reason for the discrepancy?