The basic algorithm for decoding of algebraic-geometric codes corrects up to (dc-1)2-g/2 errors, where d c denotes the designed minimum distance of a code and g denotes the genus of a curve. The modified algorithm improves on this, but applies to a restricted class of codes. An extended modified algorithm that applies to all codes is formulated. It will correct up to (dc-1)/2-s errors, s is called the Clifford defect of a curve. For curves with g⩾1, this defect satisfies 0⩽s⩽(g-1)/2. The success of the algorithm depends highly on the curve that is used and the result is in the first place a theoretical result. To support the practical importance, two special cases are considered. All codes from hyperelliptic curves can be decoded up to the designed minimum distance. For plane curves that contain at least one rational point, it is shown that s⩽(g+1)/4.