refactor the binary search methods