implemented binary search for indexOf method