finish binary search implementation