simpler logic to get count