President Barack Obama added his voice Thursday to the national outrage over fatal police shootings of two African Americans this week, saying that "all Americans should be deeply troubled" by the incidents that are indicative of a "serious problem" within the nation's criminal justice system.

In a message on his official Facebook page, Obama said that he could not comment on the specifics of the incidents involving the shooting deaths of Alton Sterling in Baton Rouge and Philando Castile in Falcon Heights, Minnesota, because of the ongoing investigations. Sterling's death was captured on video by civil-rights advocates who responded to police scanner reports of a potential arrest, while the aftermath of Castile's shooting was broadcast live on Facebook by his girlfriend.

Obama emphasized that "regardless of the outcome of such investigations, what's clear is that these fatal shootings are not isolated incidents. They are symptomatic of the broader challenges within our criminal justice system, the racial disparities that appear across the system year after year, and the resulting lack of trust that exists between law enforcement and too many of the communities they serve."

The statement came out as Obama flew from Washington to Warsaw for the two-day NATO summit. He also will spend two days on an official visit to Spain before returning home on Monday.

"To admit we've got a serious problem in no way contradicts our respect and appreciation for the vast majority of police officers who put their lives on the line to protect us every single day," Obama said. "It is to say that, as a nation, we can and must do better to institute the best practices that reduce the appearance or reality of racial bias in law enforcement."

In the wake of a series of high-profile cases in recent years, including the shooting death of an unarmed teenager in Ferguson, Mo., in 2014, the Obama administration has sought to balance support for law enforcement agencies with additional scrutiny for the tactics employed by police officers in the field. The tensions in cities across the country gave rise to the Black Lives Matter political movement, and the issue of police use of force in impoverished communities has become an issue on the 2016 campaign trail.

Obama praised the Justice Department for opening a federal civil rights investigation into Sterling's death. He was shot by a white police officer while being restrained on the ground.

"All Americans should recognize the anger, frustration, and grief that so many Americans are feeling - feelings that are being expressed in peaceful protests and vigils," Obama said. "Michelle and I share those feelings. Rather than fall into a predictable pattern of division and political posturing, let's reflect on what we can do better. Let's come together as a nation, and keep faith with one another, in order to ensure a future where all of our children know that their lives matter."