added ifelse and switch