Alabama’s public schools were rated among the worst in the country, according to a new rankings.

Wallethub looked at a range of 29 factors to determine which states had the best schools. The factors were wide-ranging, including such things as high school graduation rates; Blue Ribbon Schools per capita; math and reading test scores; median SAT and ACT scores; teacher/pupil ratio; school safety and discipline rates; and the share of licensed teachers. You can see the complete methodology here.

Alabama came in at number 46, ahead of only West Virginia (47th); Mississippi (48th); Arizona (49th); Louisiana (50th); and New Mexico (51st).

Alabama ranked 44th for quality and 47th for safety. In the individual categories, Alabama ranked 48th for lowest math scores.

States with the best schools, ranked high to low are:

1. Massachusetts

2. New Jersey

3. Connecticut

4. Virginia

5. Vermont

6. Minnesota

7. New Hampshire

8. Nebraska

9. North Dakota

10. Wyoming

11. Wisconsin

12. Delaware

13. Kentucky

14. Iowa

15. Maine

16. Illinois

17. Colorado

18. Rhode Island

19. Maryland

20. Kansas

21. South Dakota

22. Indiana

23. Utah

24. New York

25. Montana

26. Florida

27. Pennsylvania

28. Ohio

29. Washington

30. Missouri

31. North Carolina

32. Idaho

33. Texas

34. Tennessee

35. Georgia

36. Hawaii

37. Michigan

38. California

39. South Carolina

40. Oklahoma

41. Arkansas

42. Alaska

43. Nevada

44. Oregon

45. District of Columbia

46. Alabama

47. West Virginia

48. Mississippi

49. Arizona

50. Louisiana

51. New Mexico