Change the if-else to case matching which is easier to cover more cases in the future.