I think the same `lists:foreach/2` trick should be used here with `lists:keymember/3`, your code will fail with `badarg` on improper lists and with `case_clause` if the found tuple isn't a pair.