added feature to append messages to DOM.