Defining a class inside a function has led to issues in the past.  This class will be redefined each time the function is called.