Then, apparently, you're doing something wrong. Time to debug your code to see what is undefined. Then correct that.