changed IFELSE to CASEWHEN