A homeless man who attempted to rob a downtown Vancouver bank because he wanted a bed in jail was sentenced Friday to 20 years in prison.

Robert D. Hobert, 56, pleaded guilty June 20 to first-degree attempted robbery of Chase Bank on April 11 as part of a plea deal with the prosecution.

By pleading guilty, Hobert avoided a potential life sentence. He has an extensive criminal history, including an armed robbery in 1979 in Clark County and a robbery in 1989 in Kingman, Ariz.

The prosecution could have argued that the attempted robbery was Hobert’s so-called “third strike” and that he is a “persistent offender.” A persistent offender automatically receives a life sentence without the possibility of release, under state law, though Hobert’s court-appointed attorney Jeff Sowder said he would have challenged that.

Hobert wrote in a signed declaration that he accepted the plea bargain because “I want a place to take a shower and eat that is guaranteed.”