refactor case blocks beautifully