fixed UnboundLocalError when no cdp is present