fix bug in formula of if-then-else