added check for the head in list destructor