updated to reload chat window properly when new messages arrives