Add cube merge function