better algo for variance