more robust topcount (hopefully)