As I told you before no time to really check this but there is something I did
see:
You don't need the LoopInd, since you do not do anything with it.
You first declare it, and then set its value to 1 and then check if it's more
than 1 you exit the loop. It is never going to be more than 1 since you never
change it later on in your code. So no need for that. Just delete any line where
the loopInd appears.