fixed off by one error for error correction