improving readability by changing cond to case