Replace Redundant Check before Assignment issue with Pattern Matching