Move the count call outside of the iteration

Fixes #4