finished naive count function