The gym at Riverside Correctional Facility is through the metal detector, two heavy doors and down the hall. 

There's a basketball court like one you'd see at any high school, except there's a friendly and beefy corrections officer on guard near the three-point line.

Sixteen stationary bikes are set up in a half circle in the corner. One or two women are struggling, but on bike number two, Lakiesha Montgomery, 32, is peddling fast and singing along to Nicki Minaj's song "Fly."

She's heard from other inmates that spin class is tough.

"I didn't think I'd be able to keep up, I'm not the skinniest thing in the bunch," she said.

But she is keeping up.

'It helps you get through' 

Montgomery has two teenagers and a toddler. Between her job and her kids, she says she never worked out back at home in Southwest Philadelphia. At Riverside, Montgomery spends time in the prison yard most days but doesn't get much exercise there either.

"The outside is not a real outside, it's like a mini garage. They have a basketball court there, but I don't play basketball, it's a lot of people that come out so you don't have room to really jog or walk, it's like you sit out to just get some air," she said.

She has arm tattoos and her hair is braided back into cornrows. She has sprinkle of freckles across her nose and high cholesterol.

She's been at Riverside for four months. "First time, last time," she said and meantime, spin class is something to do.

"Keep away frustration being locked up, it helps you get through," Montgomery said.

In 2011, biking advocates from the non-profit group Gearing Up persuaded prison administrators to let them bring in bikes to teach indoor cycling. Founder Kristin Gavin says before that she had mentored ex-offenders out in the community.

"Over and over I had conversations with women who were saying: "While I was incarcerated, I put on 60 pounds, I put on 70 pounds.' How long were you in prison for? 'Six months,'" Gavin said.

"I don't anticipate that this is a Philadelphia-centric problem," she said.

Prison weight gain highest among women

When the Department of Justice surveyed the health of state and federal inmates, a 2012 study found that women are more likely than men to be obese.

Separately, a study of prison health in Kentucky found greater weight gain for women compared to men. Researchers documented the entering weight and weight at release for prisoners. Women on average gained nearly 11 pounds; the gain for men was 2.5 pounds.

Study author Madison Gates, an assistant professor with the Institute of Public and Preventive Health at
Georgia Regents University, says there aren't many prison-health studies yet, but health researchers are interested.

"There are very few offenders who go to prison forever, most are released, and return back to their community, so it's really a public health issue," Gates said.

To better understand the weight gain differences between men and women, Gates says he'd like to see more studies on the recreational and other facility resources available. "Is it a built-environment issue with respect to gender?"

Gearing Up is working with researchers at Temple University to track the weight, body image and sense of connectedness of the women who spin at Riverside Correctional. The study was just eight weeks long and small, but they've already found improvements in at least one measure of heart health.

Gavin says often the women come to class initially for one reason, then later find other reasons to keep coming back.

"I can speak to myself, if I weren't given the opportunity to be physically active, I'd probably go a little crazy. I probably wouldn't be able to manage my emotions, my temper, my anger. I think anger management is a huge issue for a lot of women who are in the prison they are victims of trauma and abuse," Gavin said.

And, of course some of the women have hurt other people.

Exercise can be catharsis, a way to release all sorts of emotions.

Erica Tibbetts from Gearing Up often leads the spin class. She has a short mop of red hair and the swoop of her bangs gets more and more damp with sweat during her hour-long class. For 60 minutes she offers the women smiles and encouragement while playing a soundtrack of booming songs from artists such as Lauryn Hill, TLC and Whitney Houston.

"I see you Jean. All right Kiesha. All right Amanda," she says from her bike at the front of the class as she guides the women through sprints.

A chance to shake off depression, stress and the past 

Tibbetts is in bike shorts. Everyone else has on prison blues: long navy pants and a white t-shirt.

"The worst seems to be women don't have good sports bras in here," she said.

No one has a water bottle and exercise shorts aren't allowed. Tibbetts says the women come to class anyway and work with what they have. Jean Dombrowski on bike 10, for example, wrapped a long piece of scratchy brown paper towel around her head—to make a sweatband.

Climb on a bike and there's a sense freedom, even if you're not going anywhere.

At beginning of class, one by one around the circle, the women share their intention for the ride. The ritual is called 'clearing.'

Christina wants to leave behind shakedowns. Jean wants to forget 'cough and squat.' Sheik is leaving behind 'wrongful mistakes.'

Others want to shake off the past, stress and depression.

Making diet and health a priority 

In a 2010 survey, women at Riverside gained about 36 pounds in a year. But after some changes at the facility that weight gain dropped to 26 pounds when the medical team checked in 2015.

Bruce Herdman, the prison's chief of medical operations, says weight gain is a problem, but it's not the most urgent problem.

"The chlamydia rate--6.6 percent on admission. We'll treat a thousand people for HIV. The hepatitis C rate here--largely because of intravenous drug use—is 13 percent. Then you have hypertension, diabetes, all the regular things," he said.

The prison system is working on the women's weight problem.

But first, the medical team had to challenge some conventional wisdom. Herdman said some security staffers thought gaining 30 or 40 pounds was a good thing for people who entered the facility drug-addicted and emaciated. But that scenario wasn't the reality for most entering jail.

"We just had to disprove that," Herdman said.

The prison pays Gearing Up to hold spin class three times a week, and there's also an occasional yoga class. But the big change was the food. The meals are certified 'heart healthy' by a nutritionist but there's a lot of it.

Portion sizes are smaller now. Last year, the prison cut calories from nearly 2,900 a day to 2,500 for men and women.

That helped, but prison meals aren't the only food around. A favorite do-it-yourself dinner is called chi-chi.

"It's where you mix ramen noodles with Cheese puffs. You put it in hot water, you put the meat inside, you can do honey mustard sauce or ranch on top, and you just put in a potato chip bag and you mix it up. It's actually pretty good, but I wouldn't eat it at home though," said Amanda Cortes.

She's been at Riverside for five years and eating like that most of that time. She says food is a way to fight boredom and depression.

"Some people get two or three trays, so they get fat like that. They take whole loaves of bread to their room," Cortes said.

So, Cortes spins to keep the weight off, and on visiting day, her 10-year-old son noticed.

"When he first seen me he was like: 'Mommy you got skinny,' so I was excited," she said.

During a year, going to three spin classes a week, Cortes dropped 90 pounds.

At the end of the Gearing Up class, just before the goodbyes and sweaty hugs, there's one last ritual.

The women don't talk about losing weight.  Instead, they share what they've brought back from the ride.

"I'm Sharina and I'm bringing sexy back. I'm Jean, and I'm bringing back my bikini. I'm Ruth and I'm brining back faith and confidence."