How quality score is calculated