Corrected Logic error