a binary search and insert util