I notice that you are returning false whether IsEmpty() returns true or false. Is that really what you want to do? Perhaps that is the source of the problem. Otherwise it must be something in the IsEmpty() function. You would need to post that code here to get feedback.