SUSAN WALSH/ASSOCIATED PRESS

President Barack Obama condemned violence against police Sunday and even said excessively nasty rhetoric against police can hurt the cause of criminal justice reform.

“Whenever those of us who are concerned about fairness in the criminal justice system attack police officers, you are doing a disservice to the cause,” Obama said during a press conference in Spain on his way home from a NATO summit in Poland.

“But even rhetorically,” Obama continued, “if we paint police in broad brush without recognizing that the vast majority of police officers are doing a really good job and are trying to protect people and do so fairly and without racial bias, if the rhetoric does not recognize that, then we’re going to lose allies in the reform cause.”

The president’s remarks came days after a sniper murdered five police officers in Dallas during a Black Lives Matter protest over two high-profile police killings of black men in Minnesota and Louisiana. A reporter had asked the president what advice he would give the Black Lives Matter movement in the wake of the Dallas killings, noting that Obama has previously suggested the movement, which he supports, can occasionally be counterproductive.

“Now in a movement like Black Lives Matter there will always be folks who say things that are stupid or imprudent or over generalized or harsh,” Obama said, adding that well-meaning protesters shouldn’t necessarily be held accountable for everything said in the heat of a protest.

“I would just say to everybody who is concerned about the issue of police shootings or racial bias in the criminal justice system that maintaining a truthful and serious and respectful tone is going to help mobilize American society to bring about real change and that is our ultimate objective,” Obama said.

Some conservatives have said Obama’s acknowledgment of racial disparities in law enforcement made him partly responsible for the Dallas killings.