fix case/when statement for best practices