diff --git a/src/message_window.py b/src/message_window.py
index 1f2166d0b96e60c8243284f213e77cad9d641bc5..d7a09c0466c35ee19ee3463fcaf23e2ca2c54a38 100644
--- a/src/message_window.py
+++ b/src/message_window.py
@@ -480,7 +480,8 @@ class MessageWindow(object):
 			bctrl = self.get_control(jid, ctrl.account)
 			# keep last_message_time around unless this was our last control with
 			# that jid
-			if not fctrl and not bctrl:
+			if not fctrl and not bctrl and \
+			fjid in gajim.last_message_time[ctrl.account]:
 				del gajim.last_message_time[ctrl.account][fjid]
 
 			# Disconnect tab DnD only if GTK version < 2.10