implemented bisection method