The U.S. housing market has been in steady recovery since the housing crisis, and increasing numbers of investors are trying their hand at home flipping: the purchase, renovation, and subsequent sale of a property in a relatively short period of time. While home flipping is costly and notoriously risky, a number of housing markets are producing extremely profitable returns on investment.

Home flippers in nine metro areas have been able to return a profit of at least 80%. In Pittsburgh, flippers more than double their money. Of course, turning a profit from home flipping is by no means a guarantee. In one in every 70 zip codes reviewed by RealtyTrac, practically all flippers lost money in 2015.

24/7 Wall St. reviewed the 25 most profitable home flipping markets using data from housing market tracking company RealtyTrac. For the purposes of RealtyTrac’s analysis, a flipped home is a property that has been bought and sold within a 12 month period.

In an interview with 24/7 Wall St., Daren Blomquist, senior vice president at RealtyTrac, explained, “The best window of opportunity is when a market is about to bottom out.” In these struggling housing markets, investors are often able to purchase properties at a significant discount, and can sell at a premium as home prices go up.

17. San Diego-Carlsbad, CA

> Return on investment: 30.8%
> Avg. gross profit: $102,500
> Avg. flipped price: $435,000
> Number of flips: 2,398
> Flips, pct. of home sales: 6.3%

The median purchase price for flipped properties was less than $100,000 in all but two of the 25 best cities to flip a home. Nationally, homes are flipped on an initial investment 25.9% below the estimated market value. In all 25 metro areas, the average discount for flippers was greater than the national average discount. In 14, the discount was a 40% or greater discount compared to local median purchase prices.

For property investors looking to turn a profit in the short term, the availability of steep discounts is more attractive than soaring home prices. Home prices grew by 13.8% across the nation over the five years since 2010. In nearly all of the 25 most profitable markets for home flipping, prices grew slower than the national growth rate, and in only one market did growth exceed the national rate. In five of the metros, home prices actually declined over that period. Yet, in the past 12 months, flippers have been able to turn massive profits in all of these areas.

“The amount of money they’re risking is less and the barrier to entry is lower in those markets,” said Blomquist.

At the other end of the spectrum, the markets where home flipping has relatively low average returns on investment are counterintuitively some of the nation’s hottest housing markets. The housing market in urban regions such as San Jose-Sunnyvale and Santa Rosa, California; the Austin-Round Rock, Texas area; or Salt Lake City, Utah have been strong with some of the largest home price increases in recent years. Yet, none of these areas are especially lucrative for home flippers.

This pattern does not mean that high levels of profitable home flipping is a sign of a poor housing market. According to Blomquist, a healthy housing market should have a moderate level of home flipping, estimated at no greater than 10% of all home sales. Except for the Memphis metro area, where flips accounted for a nation-leading 11.1% of all property sales, the level of home flipping in every metro area considered did not exceed that threshold.

While home flippers have far less influence over the housing market than they did before the housing crisis, the practice is gaining popularity as the housing market rebounds. Home flipping nationwide peaked in 2005. That year, there were many more metro areas where home flips accounted for more than 10% of all home sales.

Today, flips account for 5.5% of all home sales nationwide, down from 8.2% a decade ago, and from 7.3% five years ago. Compared with the end of 2014, home flipping as a share of all sales in the fourth quarter of 2015 had increased from 5.3% to 5.5%.

Another perspective on this trend can be observed by looking at the share of flipped homes that were purchased in cash. Of flipped homes in the United States, 70% were all-cash investments, and in 14 of the most profitable home flipping markets, at least 80% of flips were cash only deals.

Cash deals are most common in extremely distressed markets, but with conditions stabilizing across the country, the share of all-cash flips has fallen for five consecutive years. “We’re starting to see the pendulum shift because a broader spectrum of people have confidence in the housing market,” Blomquist said. For investors relying on financing options, rather than strictly cash, the personal risks are lower, but the risk of default can have broader consequences on the market. While the trend of a decline in all-cash purchases signals a healthier housing market, this may expose these markets to greater risk of economic turmoil down the road.

Click here to see the 25 best cities to flip a home.

Click here to read our methodology.