added unread message counters logic