refactor: put get unseen count in a separate function