added some checks and logging of clientd_id