Improve tag validation