ecc algorithm