Also, my links were intended to point you to some potential errors in your code.
For example
a=1
assigns the value 1 to a, it does not test whether a is equal to 1. For that you need
a===1
You may have other similar issues in you code, but as Daniel recommends, it cannot be examined without the actual code so that we can test it.