fixed ifThenElse, still problem with while