updated parser to handle multiple closing tags