New histogram based algorithm