tried to add a switch case instead of ifelse. failed..