script to merge records