updated query for quality value