Method and apparatus for correcting errors in digital signals