Measuring the quality of democracy