updated quality function