fix metadata rewrite bug