wrote the merge function!