Implemented gradient mid point