optimized binary search added