correction of a bug when ng /= 0