refactored case_statement