make it o(log n) again