added getAllMessages() function