Corrected condition logic