Use ifelse instead of if ... else