Error: Attempt to index local '' (a nil value)

I have an error in line 136 while running this lua code - it is an extension for a personal finance management tool.

ibkr.lua:136: attempt to index local 'summary' (a nil value)

It seems like nil is already assigned to

local if statementContent == nil then

What can I do to fix this?

Code snippet:

https://pastebin.com/xT8AT8ru

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum