complete merge script but not completely tested