correctly compute the objective function value