It sounds like you are trying to get help debugging some code (that is, you don't know where the problem is). If that's the case, then your question is actually off-topic on SO.
See What topics can I ask about here?, specifically:
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers.
If you actually do know where the problem is and you have a specific question, then please see How to create a Minimal, Complete, and Verifiable example
Huge walls of code are very difficult to understand and respond to and generally won't help other visitors to the site.