solution to binary_search