fix bug in binary_search where indexes would point to sorted array instead of original array