first pass at merge function