non-null check before dereferencing the cpt's name in cptwrite()