Logic error correction