added a merge function