getSpecialTags function modified again

Try to catch incorrect closing tags and put them at their correct
location