fix cdr logic