If you still need help I have some ideas to make your code much more compact. The whole style the program is written in is quite awkward. But that does not matter much. As I guess you are quite new in your learning curve. If you need more help can post a schematic.