Conditional logic is not functioning