James B. Comey is a former FBI director and deputy attorney general.

A police officer I know asked me for advice on handling criticism. This is what I told him:

It’s hard to both care what people think and not care, but it is essential, especially in a public-trust business such as law enforcement.

I think of it as a window. I can’t open it all the way or the hate will overwhelm me. But I have to open it some to let in thoughtful voices of criticism because I could be wrong (and because it is so easy to convince myself I am right). Law enforcement has a tendency to slam the window shut under pressure.

And I understand that instinct to slam. There is a sense of frustration that the job is hard and thankless, and that cops aren’t the root cause of the underlying problems but still get blamed for them. Context is frequently missing, and an entire group gets judged by anecdotes, not data.

Second, leadership is frequently weak, because police chiefs are often afraid of their political masters and afraid of their rank-and-file officers, in the sense that the labor unions can really make their lives difficult.

Third, the pressure to conform in law enforcement is extraordinary. The reasons make sense. Cops depend upon each other, often for their very lives. It is like the bond among members of a sports team, but magnified because the season never ends and the stakes are much higher than just losing a game. And when the world is hating you as a group, your group gets tighter, even when getting tighter is self-defeating.

Still, the best cops will find a way to keep the window open. Because there is a lot that needs improvement in policing. The things I see: Bad cops just moving to a new department; cultures of lying in many places; overuse of SWAT; low pay; bad leadership; de-escalation seen as weakness; and poor fitness, which makes all encounters ratchet quickly to weapons and other tools. I’m sure your list is longer.

I’m concerned about a culture that has emerged among some cops suggesting they are warriors standing as the last line of defense in a battle between order and chaos. I see the “sheep dog” tattoos and stickers suggesting the job is to protect us from wolves; I see the bumper stickers on off-duty cars of “The Punisher” comic book hero, who brings miscreants to violent justice. You aren’t fighting a war; you are serving a community.

I understand the sense of unfairness that good cops feel about being grouped with the worst among you — and being assigned responsibility for problems you can’t solve. Law enforcement has improved dramatically in the past five years in its use of force in general; then come four Minneapolis police officers, and their videotaped actions help undo in a moment any perception of progress.

And “defunding” the police makes sense only if it means relieving the cops of responsibilities they shouldn’t have — such as truancy, mental health interventions, homelessness and substance abuse. If people want to pay for someone else to handle that, and leave the police to the business of law enforcement, it would be a blessing.

The really hard problem? Relations between police and the black community. The relationship has long been troubled. Crime in some communities is real, enduring and heartbreaking. That’s a legacy of 400 years of America mistreating black people. Policing was part of the way we did that, but fully enlightened policing today will not solve the underlying problems.

I don’t know what to do about that, except try to frame it both positively and negatively. Law enforcement will be better in five years as a result of this (just as Ferguson more than five years ago spurred improvement). But many problems faced by the black community likely will not be, which leaves me very sad.

Policing is experiencing a perfect storm, and the combination is uniquely toxic: unprecedented pandemic anxiety, economic pain, an appalling visual record of police misconduct, political polarization, historically low crime rates and horrific national leadership. The combination feeds the focus on cops in a way we have never experienced.

I’m sure a lot of cops are thinking: “Okay, let crime explode and let good people flee law enforcement, and then they will appreciate us.” That would be a terrible attitude for a profession built on serving others.

So my advice is to keep the window open, find ways to improve and resist cynicism. Cops are never going to be appreciated fully. So what? You don’t become a cop to hear applause. You become a cop because you want to do hard things that make a difference. Please stay with it; all communities need good cops now more than ever.

Watch more Opinions videos:

Read more: