Conn. (WTNH) — Teachers are a vital part of society, but where are teachers most valued? According to a new study, both Hartford and New Haven metro areas were ranked among the top 20 places to be a teacher.

The study, conducted by SmartAsset, looked at 137 of the largest metro areas to determine the best places to teach, taking employment, income, housing costs, classroom size, and school funding into consideration.

Out of the largest metros in the country, the Hartford-East Hartford-Middletown metro took the No. 4 spot. In this metro, teachers earn above $80,000 annually, which is the 18th-highest overall salary, according to the study. Teachers in these districts also receive substantial monetary support, and on average, their classrooms are smaller in size.

The Hartford metro fell behind Syracuse, New York and Buffalo, New York, leaving the Youngstown-Warren-Boardman metro in Ohio and Pennsylvania to take the top spot as the best place for teachers to work. The study found that there is a combined estimated 4,600 teachers in these districts and a 15.52% increase in average income over a one-year period.

While various New England cities made the top 20 list, including towns in Maine and Massachusetts, Connecticut metros actually made the list three times.

In addition to Hartford, the Bridgeport-Stamford-Norwalk metro ranked No. 9 as its average income for students stands at $87,160. Teachers in this area can also expect smaller classrooms on average, as well as higher average spending per student.

The New Haven-Milford metro area also made the list, taking the 19th spot. In this area, teachers make an average of $76,510, with housing estimating over $1,300.

As the school year looms closer, it’s important to realize both the challenges teachers face, as well as the impact they have on their communities.

See the full study and how each of the top metros ranked via SmartAsset.