A man standing trial after being accused of robbing a bank in California was likely left with a bad taste in his mouth after an apparent bid to convince the jury he was insane proved unsuccessful. While he was testifying at San Luis Obispo Superior Court last week, Andrew Gilbertson pulled some feces out of his pants and ate it. He was on trial for robbing a Bank of America branch in the central California city in 2013. Scroll down for video . Andrew Gilbertson was standing trial in San Luis Obispo Superior Court in California for a 2013 bank robbery . While he was testifying, the 40-year-old defendant reached into his pants, pulled out feces and then ate it . Gilbertson's attempt to convince the jury he was insane didn't work and he was found guilty of robbery . Gilbertson, 40, was pleading not guilty by reason of insanity and claimed he heard voices in his head, according to the San Luis Obispo Tribune. His defense attorney, Brian Buckley, apologized after the excrement eating. Buckley said: 'When I said this was going to be an unusual case, that wasn't what I was expecting.' Despite his unorthodox attempt to convince the jury he was insane during the robbery, Gilbertson was found guilty of robbery and burglary. Deputy District Attorney Dave Pomeroy told the jury, who took about half a day to hand down the verdict, that Gilbertson was sane when he robbed the bank and when he ate his poop. Pomeroy said: 'That was upsetting a couple of days ago. 'Obviously, it was designed to produce emotion.' He added that Gilbertson showed off his hands during the stunt to 'be sure you all clearly understood what he had in his hand and what he was doing'. The district attorney argued Gilbertson  pulled off the heist because he 'really, really likes methamphetamine' Gilbertson said the Virgin Mary told him to disguise himself and rob the Bank of America in San Luis Obispo . He has previous convictions for sexual battery, aggravated battery and failure to register as a sex offender . Before he ate his waste, Gilbertson told the jury the Virgin Mary told him to wear a disguise and rob the Bank of America, KSBY reported. The district attorney argued Gilbertson had a much different reason for pulling off the heist. Pomeroy said: 'He just wanted methamphetamine. 'He testified that he really, really likes methamphetamine.' Gilbertson has previous convictions for sexual battery, aggravated battery, failure to register as a sex offender and car theft. A sentencing date for his latest conviction has not been set.
Andrew Gilbertson on trial at San Luis Obispo Superior Court in California . He was accused of wearing disguise and robbing Bank of America in 2013 . 40-year-old defendant was pleading not guilty by reason of insanity . Prosecutors argued he was sane during robbery and when he ate the poop . DA said he pulled heist because he 'really, really likes methamphetamine'
Jury deliberated for half day and found him guilty of robbery and burglary .