PCH algorithm working