finished dict merge function