modify case-when for readability