Added Brent's code.