To make it easy for people to help you please modify your post and use the code button </>
so your code looks like this
and is easy to copy to a text editor. See How to use the Forum
Your code is too long for me to study quickly without copying to a text editor.
And you have not told us what the program does or what you want it to do differently so that we might know which part to look at.
...R