added cases instead ifelse