Refactor out giant case statement into a hash