Well, if you can fix it that easily in the code, it should take seconds to fix the wiring by making the equivalent changes. Maybe post a picture of your wiring. One where we can trace exactly where every wire starts and ends. If you find you can't take a clear picture showing where each wire goes, then I think we may have located the problem.