Modified Cpg class to check for correctness of input.