changed calculation of cBar to be more intuitive and added some more comments
solution of the new algorithm is not the same as that of the old one, so one of the two may be wrong