implements basic binary search