Convert a few matches to if let's to reduce code length