fixed error in finding closing tag