diff --git a/src/roster_window.py b/src/roster_window.py
index 321fb00730d8c325bd510887fca5b827c01564fe..75e8f6eb0c5626e902c42685cf6471567e146388 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -1632,7 +1632,8 @@ class RosterWindow:
 			gajim.contacts.add_account(account)
 		if account not in gajim.groups:
 			gajim.groups[account] = {}
-		for jid in array:
+		# .keys() is needed
+		for jid in array.keys():
 			# Remove the contact in roster. It might has changed
 			self.remove_contact(jid, account, force = True)
 			# Remove old Contact instances