refactoring
implicit using binary search