change if/else to case/when