Fix bug when tagging elements