added new mda_merge function