adding part of error correction algorithm