MIAMI (CBSMiami) - A Miami police officer showed restraint and professionalism after being confronted by an aggressive man who would not back down.
It happened Thursday on Bayshore Drive in front of Margaret Pace Park.
According to police, the officer who was investigating something else in the area noticed a man standing by his patrol car trying to open the door using the handle.
When the officer approached the man, later identified as 37-year-old Derek Peivandi, and asked him what he was doing, Peivandi stated "Naw am trying to steal that (expletive)," according to the arrest report.
Police said Peivandi then ran toward the officer with something in his hand yelling "I'm going to kill you."
"Hands up, hands up," yelled Officer James Marte.
"Suddenly he's confronted by the same male banging on his window tell him he's going to kill him," said Assistant Miami Police Chief of Field Operations Manny Morales.
What happened next was captured on video by Emmanuel Alberio who posted it on Instagram.
As Peivandi continued to walk forward, Marte repeatedly told him back up, as he himself slowly backed up in an effort to keep some distance between the two.
Police said at one point Peivandi spat at the officer.
WATCH: Miami Police Officer Confronted By Aggressive Man
In an effort to stop Peivandi's aggressive advance, Marte deployed and discharged his Taser and called for back up. The shock seemed to have little effect.
"I yelled out to him to calm down, calm down. He was in a zone where he wasn't going to hear anybody," said Kerri Sauer as she watchd it unfold.
Sauer said she feared it could go downhill quickly as she watched Peivandi get repeatedly tased, while not following police commands.
"It really could have when he didn't comply. He's got his hands in bags. The police didn't know what's in his bags. They know this guy, he's generally pretty harmless, he just talks to himself. But it could have gone south really, really fast," she said.
Police said the Taser shocks didn't work because the prongs got caught in Peivandi's clothes.
Morales said their officers put their training to good use and use de-escalation tactics.
"Officer Marte gave him verbal commands and he followed his de-escalation training, he backed up," said Morales.
When several officers arrived, they all commanded Peivandi to lay on the ground, but he refused and turned away from them.
That's when they moved in and forcefully took him down.
Peivandi has been charged with aggravated assault on a law enforcement officer, burglary, disorderly conduct, and resisting arrest without violence.
In bond court, prosecutors learned Peivandi is homeless.
"How long have you been in Miami for?" Judge Mindy Glazer asked.
"About 6 months," Peivandi replied.
"Where were did you live before that?" Judge Glazer asked.
"Michigan," he replied.
Prosecutors say Peivandi told police later he wanted to be taken into custody.
"Post Miranda he confessed to trying to burglarize the police car, he wanted to get arrested to get a bath, a meal, and a place to sleep," the prosecutor said.
Alex Piquero is a criminologist at the University of Miami who's studied use of force issues for years. He thinks this is an example of good policing.
"Officers and police departments have had a total re-evaluation of how they approach suspects in these kinds of situations. I think those policy changes err on the side of using the least amount of force for as long as possible," Piquero said.
Sauer said the police responded, "Beautifully, excellent. It was the best outcome you could hope for."
Peivandi is being held in lieu of a $7,500 bond. During much of the stand-off, there was a concern about what was in the bag Peivandi was carrying. Police said it turned out to be flip flops.
for more features.