Moved _input call to after the inner integration loop.