ImageID recovery

Dear all,
I have a stack of 21 frames. I want to subtract two frames, make them composite, remove one channel and stack the images again.
The problems is that when ImageJ make them composite the imageID changes. As a consequence, when I stack the images again, the ones I made composite are located at the end of the stack (so, not in the correct order).

Is there any way to reset the imageID number?

I wrote this macro

DapiRemove();
function DapiRemove() {
images = getList("image.titles");
	//Array.print(images);
	// find first image that contains the title_part
	found=false;
	for(i=0; i< images.length;i++) {
		if(matches(images[i], ".*0013.*") || matches(images[i], ".*0016.*")|| matches(images[i], ".*0019.*")|| matches(images[i], ".*0021.*")) {
			selectWindow(images[i]);
			originalname=getTitle();
			originalID=getImageID();
	        run("Make Composite");
	        run("Channels Tool...");
			Stack.setActiveChannels("110");
			Stack.setActiveChannels("010");
			run("Stack to RGB");
			rename(originalname);
		}
		}
		}
run("Images to Stack", "name=new title=[] use");