As you're paying out your state taxes, take a minute to think about where all those tax dollars go? It turns out that some Americans get a much better return on their state-taxes investment than others, depending on which state they live in. It's not just a question of how low the taxes are. It also depends on what you get back for paying them.

To determine which states had the best and worst taxpayer return on investment (ROI), WalletHub conducted a survey that compared the tax rates to the quality and efficiency of state services. The primary categories that were assessed to rank the states included education, infrastructure and pollution, healthcare, safety and the economy. Here’s a closer look at the top five states on both ends of the spectrum. (For more, see FYI on ROI: A Guide to Calculating Return on Investment.)

States With the Greatest Taxpayer ROI 

1. New Hampshire The Granite State received stellar ratings across the board, most notably for safety, education and the economy. “New Hampshire has a good balance of generating a lot of money for its public university system and its kindergarten-to-12th-grade schools,” Jill Gonzalez, a spokeswoman, told CNBC.

2. South Dakota This ROI can be attributed to the states top ranking in the healthcare category. The Farmland State has the fourth best hospital system in the nation and the largest number of beds per 1,000 residents. South Dakota also fared well in terms of infrastructure and pollution.

3. Colorado Known for its scenic mountains and superb healthcare system, Colorado also gives its taxpayers a fairly high rate of return with regard to the economy and education. In February of 2016 the unemployment rate was 3.0%, which is fairly low compared to the nationwide rate of 4.9%, as noted by the Bureau of Labor Statistics

4. Virginia Ranked 7th and 8th in the economy and education categories, respectively, Virginia also snagged a decent safety rating, as it was in the top five of states with the lowest violent-crime rate and recognized for its strong school system. 

5. Florida The Sunshine State performed fairly well in all of the categories. It also clinched the number three spot for the best roads and bridges.

States With the Worst Taxpayer ROI

50. North Dakota The state landed at the bottom of the list for taxpayer ROI. Although North Dakota boasts low pupil-to-teacher ratios and high SAT scores, the expenditures at the public elementary and secondary day schools are among the lowest in the country. In addition, “They are really not looking into their higher education spending as much as they should be,” Gonzalez told CNBC.

49. Alaska Receiving low rankings in the education, healthcare and safety categories, Alaska has dropout rates, reading test scores and hospital systems that are among the worst in the country. It also landed on the top five list of states with the highest violent-crime rates, with a figure of 6.36 per 1,000 residents.

48. Hawaii Hawaiians are also getting the shorter end of the stick on their tax dollars. Thanks to the poor water quality and volume of roads and bridges that need work, the Aloha State took the third worst spot on the list.

47. New York The Empire State seemed to miss the mark in the infrastructure and pollution category, and the hospital systems were another cause for concern. The school system quality and safety rankings were also low, despite the high expenditures in the public elementary and secondary day school systems.  

46. Delaware The state received mediocre rankings in each of the categories, but Delaware’s health and education stats were especially alarming. Its students had some of the lowest SAT scores in the nation.

The Bottom Line

 Some American taxpayers receive a substantially greater return on the money they pay out than others do. There are different reasons why states miss out and some results may surprise people who don't live in those states. (For more, see The Best and Worst States to Retire to in 2016.)