Add new both-sides-merge function