added merge metadata function