Your pseudo-code makes little sense, it would be really easier if you could reproduce the issue in a blank capx.
Even if in the end the program does nothing, at least we would be able to visualize exactly what you did.
As far as I've tested local variables, I haven't had a single issue with those, so I'd be inclined to think it's an issue in your code, but can't pinpoint it from the pseudo code here.
Anytime you request for help, just try to provide a small capx, it helps a lot.