updated the query that is used to retrieve latest messages in various DAO classes