corrected logical error