The code you posted cannot compile, so any reason why it doesn't run or function as you expect is pure conjecture.