Modify bsearch ruby code