modified ec_merge script