Use proper pattern matching instead of case-operator