Hm, that looks complicated. Isn't is possible to define a local normal javascript function instead?