Refactoring and fix a match-case to be exhaustive