further optimized tanimoto calculation