countUnseen function