Sometimes there are meshes that doesn't have materials, so make sure to check this case before extracting the name.
instance()
instantiate()