fix tag logic