use faster version

For n = 1e6, older is 0.536, new is 0.26