ccd algorithm