Residents of Montgomery County are the healthiest in the state, knocking Howard County out of the top spot, according to an annual report of health rankings released Wednesday.

Baltimore City was the unhealthiest, although it has seen improvements in many areas, according to the report by the Robert Wood Johnson Foundation and the University of Wisconsin Population Health Institute that looks at the overall health of every county in every state.

The rankings are made by analyzing 29 factors that influence health including smoking, high school graduation rates, employment, physical inactivity, and access to healthy foods.

The five healthiest counties in Maryland are Montgomery, Howard, Frederick, Queen Anne’s, and Carroll. The five counties in the poorest health are Baltimore City, Caroline, Allegany, Dorchester, and Somerset.

Baltimore city health officials said there have been steady improvements in health outcomes including infant mortality, rate of low-birth babies, violent crimes, preventable hospital stays and adults who smoke.