Optimize innerContext function literal

Go does not perform well with recursion, so I have reprogrammed this function with a for loop. I also decided to set up a condition to optimize the number of required loops.

The inner function literal still needs to be optimized as well since it also relies upon recursion.