Bug when deleting an object