Problem with the conditional logic