The ‘repeat with’ loop assigns a reference to a list item to variable aMf. (It’s a common mistake to assume it assigns the item itself.) To retrieve the item being referenced, get the reference’s contents property:
repeat with aMfRef in mf
if aMfRef's contents is in newidmatches then set the end of nimf to aMfRef's contents
end repeat