finished calculation of objective function