decomposed executeEndTag into replaceSimpleTag and replaceLoopTag