fixed the issue of returning empty array of messages