Corrected logic