Working DDS code version 1