add binary-search version for faster startup