Use bisect module for bisection