add gencode to ifelse stmt