factored out metadata comparison