I’m having a little trouble understanding what your error is exactly. Could you provide a more minimal example (or provide the above code in a gist or pastebin so that formatting is not an issue) that causes the error?