added count_samples, addressed comment by @adamrp