Is there any specific reason for creating a class inside a function? (especially one that's called so much)