fixed errors in CG