more optimized log2