Fixed the key value tag logic