Fix bug in assigning tag value