This anonymous class smells funny. I think you could refactor this into a new class (with its own file) and take the parameters in this method (bound here by closure...) in a constructor and clean this up a bit.