I wonder if some `select/match`-fu would reduce the amount of iteration here.