Edit: But, I think you are correct and its your line posted.
After re-reading the code, I saw the issues you hinted at.
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson