Fix conditional logic