changed a way of computing first local minimum