moved tool invoke to end