Convert some ifs and elses to a nice concise match