"How the heck" - yes indeed. How the heck can we give any ideas when you give us no information except that you have copy and pasted some code.

Since that is all we have to go on, I will guess that you fail at copy & paste. A possible alternative is that you have some path handling that doesn't make sense from one place but does in the other.