There are better and worse states to buy a home, much of which has to do with price. First-time homebuyers have a hard time competing in the real estate market, but looking in the right state can make buying your first home much easier.

According to a recent study from Bankrate, first-time homebuyers looking for affordable homes should avoid major markets on the east and west coasts, but will find friendlier homebuying conditions in the Midwest. The country’s inventory shortage means affordable properties are harder to come by everywhere, so first-time homebuyers should act fast no matter where they’re looking.

Here are the best and worst states for first-time homebuyers and what you can do to improve your chances of getting a great deal on buying your first home.

The best states for first-time homebuyers

The best states for buying your first home are Iowa, Utah and Minnesota, with the Dakotas and Missouri also making the top ten, according to Bankrate. What makes these states so friendly to first-time homebuyers? The data shows that, for the most part, they offer conditions every young, first-time buyer needs: affordable home prices, easy access to credit, strong local job markets and real estate markets that allow them to compete with other buyers.

But before first-time buyers rush off to these states, they should know that none of them are perfect. Iowa, for example, ranks number one in the country for housing affordability, but offers less access to credit, which makes it harder for buyers to find financing. And Utah has a very attractive job market for young adults, but comes in surprisingly low on housing affordability, so more of your salary will be spent on housing. Still, if you’re looking for a great place to buy your first home, these states are your best bet.

The worst states for first-time homebuyers

The worst states for first-time homebuyers are California, Hawaii and New York, with Massachusetts and Colorado also in the bottom ten, according to Bankrate. These states are all known for high home prices and lots of competition, yet they remain popular among Millennials and other first-time buyers. So what is it like buying your first home in these states?

In California, the study notes, the monthly cost of renting an apartment isn’t much better than paying a mortgage, so saving up for a down payment is nearly impossible. First-time buyers face a similar problem in Hawaii, which ranks well for the job market for young adults and credit availability, but comes in dead last in housing affordability. In this case, the high-paying jobs might be there but the sky-high home prices make it difficult for first-time buyers to find success. And the more popular these markets are, the harder it is to compete.

Tips for first-time homebuyers

For the most favorable conditions, first-time buyers should obviously look to states and cities with both affordable housing and strong local job markets. This allows you to spend less on housing and put more of your income toward paying down debt and saving for retirement. But if your job or other commitments keep you in an expensive area, what can you do?

First, commit to saving up for a down payment, but keep an emergency fund for unexpected expenses. You should also build your credit score so you have an easier time getting financing, and, if possible, get pre-approved for a mortgage. Working with a knowledgeable agent is also helpful if you’re new to the area. With 2017 primed to be a seller’s market, you need every advantage possible to compete with other buyers and improve your chances of buying your first home. Good luck!