Use instance variables in the template

Using local variables is deprecated.