skeleton of binary search with index