I know tdb was proud of using log's for this but heh there's no small optimisation :-)