Your definition is very big (and it uses some plug-ins I don’t have)…
To receive help it would certainly help posting a simpler version of your problem and/or explaining what (and how) are you trying to achieve.
(Having to look inside your definition to understand what you wanted to do might discourage someone… and you’ll get no reply at all)