PHILADELPHIA (CBS) –Authorities say potential tragedy was prevented by an alert Philadelphia deputy sheriff. And now a 21-year-old Philadelphia man, awaiting trial for various felonies including shooting three police officers, has been convicted of carrying a homemade knife discovered as he was on his way to a hearing at the criminal justice center.

Prosecutor Mark Gilson says defendant Nasuil Martinez was desperate, he was facing multiple serious charges, and he sharpened a metal piece in a wrist brace into a shank or shiv about seven inches long.

READ MORE: CBS3 Mysteries: Father Of Man Who Marked Grim Milestone For Philly Wants Son To Be Remember More Than Number

“Clearly the circumstances that were going on in Nasuil Martinez’s life back in April when he possessed this tend to prove that he was thinking or contemplating stabbing his way out of custody by stabbing a deputy sheriff in the courthouse, possibly taking that deputy’s gun and shooting his way out of the courthouse,” said Gilson.

READ MORE: Upper Darby Chiropractor Charged With Sexually Abusing 9-Year-Old Girl During Exam

But deputy sheriff Arthur Evans found the weapon as Martinez boarded a bus at the prison.

The defense says the metal piece was part of the brace and maintains there’s no evidence Martinez sharpened it or planned the brazen escape attempt alleged by the prosecution.

MORE NEWS: Philadelphia Business Owners Seeing Uptick In Brazen Thefts

Reported By Tony Hanson, KYW Newsradio