implemented a flexible PCG.