Create a function that essentially does $("#HubMessages").append and use that instead of referencing the same thing over and over.  Also save the $("#HubMessages") reference so you're not hitting jquery with a selector look up every time you call append.