Is there any reason why to call _set_metadata function when all metadata should be already set after for loops above?