more optimisations for jaccard index