fix ifThenElse implementation