added a binary search function.