fix bsearch bug