finished the goodness function.