building binary search functions