Implemented Newton's method and used functor