Corrected misplaced conditions