added ifelse