Fixed check for existence of tags