hack!  You can't have a variable named ctx.

You need to use a different name.  Add that variable as the first argument to your call, and add the method modifier (instead of ctxmethod) to your function definition.