added working version of merging scripts