BROOKLYN - A former NYPD detective says there needs to be trust between police and communities in the wake of recent police-involved shootings and the attack in Dallas that left five officers dead.

Retired Detective Carlton Berkley, who served 20 years on the NYPD, says his time on the force came with many close calls. 

"As a former police officer, your heart goes out when officers get hurt and killed. But my heart also goes out when civilians are killed unnecessarily by officers," says Berkley.

Officials say Alton Sterling was shot and killed by police outside a Louisiana convenience store early Tuesday morning. Then on Wednesday evening, Philando Castile was gunned down by an officer during a traffic stop. Both fatal encounters were caught on camera.

"In these two cases here, where we see officers for no reason at all, one taking out their firearm, the other firing when there's a child there. These officers have to be held accountable," says Berkley.

Then on Thursday, what was supposed to be a peaceful protest in Dallas in response to the shootings turned deadly after 25-year-old Micah Johnson opened fire killing five officers.

Berkley says to achieve peace, it will come down to establishing a cycle of trust between officers and civilians. He says the cycle of trust is when officers can trust the community to be compliant when they interact and a community that can trust its police officers to protect and abide by their training.

"When members of our community get out of control, you get what happened in Texas, and if we don't want people to get out of control and do that in Texas then we don't need our officers getting out of control," says Berkley.