add count() helper function

fixes #15