Definitely define this outside this function. As-is, you're creating a new class type each time you run the function.