Use case-when statement instead of if-elsif statement