adding tag recursively and reset ranges