mv if-else to case-when