Corrected bad logic