refactor bisect to use right fold