California is the nation’s fifth-happiest state, according to a new ranking.

The online financial website WalletHub attempted to measure happiness among the states by compiling 31 demographics, civic and economic variables to determine each state’s “emotional and physical well-being, work environments, and community and environment to achieve an overall ranking.

By this math, California was ranked behind No. 1 Hawaii then Utah, Minnesota and North Dakota. Least happy? West Virginia, Arkansas and Louisiana. When it came to the well-being slice of WalletHub’s scores, California ranked No. 4 behind Hawaii, Minnesota and New Jersey. Well-being — weighing topics from physical health and activity, depression and mental health, substance abuse through life expectancy — counted for half of the overall ranking.

Not so surprisingly, California’s poorest score by WalletHub math was its No. 24 rank among the states for work environment, which measures everything from income, unemployment and job security, job satisfaction to credit scores. Best rankings were given to Utah and Idaho, states often cited as prime pro-business locations. Work counted for a quarter of the overall ranking.

As for community and environment — a measure that looked at volunteering, leisure time, divorce rates, public safety … and weather — California ranked 12th. Idaho and Utah; Alaska and Texas scored worst.

California has ranked high in other quality-of-life scorecards. Gallup’s annual scoring of the quality of life in each U.S. state ranked California No. 14 for 2017. Best, by this math? Vermont. Worst? West Virginia. This “Well-Being Index” is built through continuous polling of American adults on five key traits of livability.