cpid_server now a separate function