Converted the if/else tree into a pattern/guard solution for merge'