Add check for object before removing it