Donald Trump speaks at a campaign rally in San Jose, Calif., last week. (REUTERS/Lucy Nicholson)

One of the more head-scratching aspects of Trump’s worldview is this: he routinely denigrates women while also promoting them within his own businesses. In a recent interview with Bill O’Reilly, he again trumpeted these efforts again, claiming he “really broke the glass ceiling” in the construction industry.

But how can we square his record of promoting women— and the fact that many of his female former employees have called him a “terrific mentor”— with the fact that he routinely insults women and calls them “pigs” and “dogs”? Or that his supporters routinely refer to presumptive Democratic nominee Hillary Clinton as a b—-? As a Washington Post reporter documented at a recent campaign stop, “At most of Trump’s rallies, there is a palpable hatred of Clinton in the air, and some of Trump’s strongest applause lines come when he attacks the presumptive Democratic presidential nominee, calling her ‘crooked’ and accusing her of playing ‘the woman’s card.’”

In fact, it’s no contradiction at all: it’s a classic example of what’s known in psychology as “subtyping.”

Consider this riddle: according to former Trump executive Barbara Res, a female supervisor who oversaw the construction of Trump Tower in 1980, Trump believes that “men are better than women, but a good woman is better than ten good men.”

But it makes sense in the context of subtyping. Subtyping is a phenomenon that allows people to maintain stereotypes of a particular group in the face of realities that contradict those stereotypes.

It works like this. If a person holds a belief that women are incompetent, finding even one competent woman means that belief is wrong. But if that person creates a subtype of “competent women,” then any woman who doesn’t fit the stereotype is not seen as evidence that the stereotype is wrong, but as a member of a completely different category. It’s a way to have your prejudice and eat it, too.

In Trump’s mind, men are better than women. However, there are certain women who aren’t like those normal women. These special creatures— these “good women”– are so different from normal women, they’re ten times as good as a man! By creating a subtype of “good women,” he absorbs (and even benefits from) information that contradicts his worldview— without having to change it one bit. Says Margo Monteith, a psychology professor at Purdue University who develops prejudice interventions, “The ultimate function of subtyping is to preserve the stereotype.”

Subtyping also helps us understand why the women who work for Trump don’t see him as sexist— they’re in the “good woman” club, so they’re not on the receiving end of his general scorn. Women who benefit from subtyping (and get its attendant special treatment) might not see the disdain other women have experienced, and therefore don’t believe it exists. This explains the female employees who have described him as great for women. Indeed, Ivanka Trump pointed to her own experience scaling the corporate ladder as an example of how fair-minded her father was. If he were truly a misogynist, she told CNN in an interview, “I wouldn’t be a high-level executive within his organization.”

False logic, Ivanka. Your dad can be a great mentor to you and a great malefactor to others. The irony is that someone who subtypes this way could be both a terrible bigot and a terrific boss. Louise Sunshine, who worked with Trump for fifteen years, told the Post, “From the standpoint of being a woman, I just thought he was phenomenal.” And he probably was— for her, and a few other women who he placed on his tiny “good” island. For the rest of us— good luck.