minor refactor for performance boost

counts.sum() not calculated twice