modified query to retrieve last 5 messages only