add state merge function