Maybe it's some of your other code that causes conflicts with this code?