add hybrid multiway merge function, modified some function arguments