It might be a little easier to get down to the problem your modified version is causing if you give us a copy of your modified version.
How do I do that?
Also, if you don't know how to do something as simple as look for a "loop", it's probably best you try not to modify add-ons yourself so that you can avoid situations like this in the future.
Not trying to call you stupid or anything, it'd just be best if you learn a bit more about developing add-ons before trying to modify one.