Working binary search