This if statement seems over complicated. It looks like you're trying to check if the pattern is not found in the metadata or if the string is not empty. There should be an easier way to write this.