adding finalize_metadata