When posting code that you have issues with, you should state the line on which the issue occurs. I shouldn't need to take 5 minutes trying to find the line to which you are originally referring. Or, better yet, you should write a small test plugin that tests just that one little thing that you are having issues with, often, people are able to discover the issue based on simply writing this test code.