The gym at Riverside Correctional Facility in Philadelphia 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 corrections officer on guard near the 3-point line.
Sixteen stationary bikes are set up in a half-circle in the corner. On bike No. 2, Lakiesha Montgomery, 32, from Philadelphia, is pedaling fast and singing along to the Nicki Minaj song "Fly."
"I didn't think I'd be able to keep up; I'm not the skinniest thing in the bunch," she says.
But she is keeping up.
In 2011, biking advocates from the nonprofit 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,' " she says. Then she would ask them how long they were in prison and she says they'd typically respond, "six months."
At Riverside, Montgomery spends time in the prison yard most days but doesn't get much exercise there.
"The outside is not a real outside, it's like a minigarage. 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 says.
She has arm tattoos and a sprinkle of freckles across her nose. Her hair is braided back into cornrows. She also has high cholesterol.
Montgomery was charged with assault this year, among other charges, and has been in county jail for about six months.
"First time, last time," she says. In the meantime, spin class is something to do.
"Keep away frustration being locked up, it helps you get through," Montgomery says.
The Department of Justice surveyed the health of state and federal inmates in 2012 and found that women are more likely than men to be obese.
A study of prison health in Kentucky found greater weight gain for women compared with men. Women on average gained nearly 11 pounds, men only gained 2.5 pounds.
Gearing Up is working with researchers at Temple University to track the weight and body image of the women who spin at Riverside Correctional. The study was just eight weeks long and small, but they've already found small improvements in resting and recovery heart rate — two preliminary measures of heart health.
Gavin says often the women come to class initially to stop gaining weight 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 prison; they are victims of trauma and abuse," Gavin says.
And, of course some of the women have hurt other people.
Exercise can be a way to release all sorts of emotions.
Erica Tibbetts from Gearing Up often leads the spin class.
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 says.
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.
Climb on a bike and there's a sense of freedom, even if you're not going anywhere.
At the beginning of class, one by one, the women call out 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.
In a 2010 survey, women at Riverside gained about 36 pounds in a year, on average. But after some changes at the facility, that weight gain dropped to 26 pounds when the medical team checked again in 2015.
Bruce Herdman, the prison's chief of medical operations, says weight gain is a problem, but it's not the most urgent health problem his team is managing.
"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 says.
The prison pays Gearing Up to hold spin class three times a week. There's also an occasional yoga class, but the big change affecting women's weight was the food. The meals are certified heart healthy by a nutritionist. There's a lot of it, but 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 the facility-provided meals aren't the only food around. Inmates also make do-it-yourself meals with food from the prison commissary. A favorite is called "chi-chis."
"It's where you mix ramen noodles with cheese puffs," explains Amanda Cortes. "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."
Cortes has been in jail for five years and eating that way for most of that time. She's facing several charges including involuntary manslaughter and is waiting for a court date. She says lots of women use food to cope with 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 says.
So Cortes cycles 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 says, smiling.
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 share what they've brought back from the ride.
One women says she's "bringing sexy back." She and everyone around the circle has a wish: "I'm Jean, and I'm bringing back my bikini. I'm Ruth, and I'm bringing back faith and confidence."
This story is part of a reporting partnership with NPR, WHYY and Kaiser Health News.