Fixing bug with tag checking where substring existed